<template>
  <div class="celebration-container">
    <!-- 左侧礼花筒 -->
    <div class="confetti-cannon left-cannon">
      <div class="cannon-body">
        <img :src="partyPopperEmoji" alt="礼花筒" class="cannon-emoji" />
      </div>
      <div class="cannon-sparkle">
        <img :src="sparklesEmoji" alt="闪烁" class="sparkle-emoji" />
      </div>
    </div>
    
    <!-- 右侧礼花筒 -->
    <div class="confetti-cannon right-cannon">
      <div class="cannon-body">
        <img :src="partyPopperEmoji" alt="礼花筒" class="cannon-emoji" />
      </div>
      <div class="cannon-sparkle">
        <img :src="sparklesEmoji" alt="闪烁" class="sparkle-emoji" />
      </div>
    </div>
    
    
    <!-- 主要庆祝内容 -->
    <div class="celebration-content">
      <div class="celebration-header">
        <h1 class="congratulations-text">项目启动成功!</h1>
        <p class="celebration-message">恭喜您成功搭建Vue3 + Vite项目框架！</p>
      </div>
      
      <div class="celebration-icon">
        <div class="trophy">
          <img :src="rocketEmoji" alt="火箭" class="trophy-emoji" />
        </div>
      </div>
      
      <div class="celebration-details">
        <p class="success-message">项目基础架构已就绪，开始您的开发之旅吧！</p>
        <button @click="triggerConfetti" class="celebrate-btn">再次庆祝</button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { confetti } from '@tsparticles/confetti'

// 导入 FluentUI Emoji
import partyPopper from 'fluentui-emoji/icons/modern/party-popper.svg'
import sparkles from 'fluentui-emoji/icons/modern/sparkles.svg'
import rocket from 'fluentui-emoji/icons/modern/rocket.svg'

// FluentUI Emoji 变量
const partyPopperEmoji = ref(partyPopper)
const sparklesEmoji = ref(sparkles)
const rocketEmoji = ref(rocket)

// 五彩纸屑效果函数
const fireConfetti = () => {
  // 左侧礼花筒效果 - 从礼花筒emoji前端喷出
  confetti({
    particleCount: 150,
    angle: 60,
    spread: 55,
    origin: { x: 0.18, y: 0.58 }, // 调整到礼花筒emoji的前端位置
    colors: ['#ff6b6b', '#4ecdc4', '#45b7d1', '#f9ca24', '#f0932b', '#eb4d4b', '#6c5ce7', '#a29bfe'],
    shapes: ['circle', 'square'],
    scalar: 1.2,
    drift: 0,
    gravity: 0.8,
    ticks: 300
  })

  // 右侧礼花筒效果 - 从礼花筒emoji前端喷出
  confetti({
    particleCount: 150,
    angle: 120,
    spread: 55,
    origin: { x: 0.82, y: 0.58 }, // 调整到礼花筒emoji的前端位置
    colors: ['#ff6b6b', '#4ecdc4', '#45b7d1', '#f9ca24', '#f0932b', '#eb4d4b', '#6c5ce7', '#a29bfe'],
    shapes: ['circle', 'square'],
    scalar: 1.2,
    drift: 0,
    gravity: 0.8,
    ticks: 300
  })
}

// Random Direction 效果 - 参考 https://confetti.js.org/more.html
const fireRandomConfetti = () => {
  // 左侧礼花筒 - Random Direction
  confetti({
    particleCount: 100,
    startVelocity: 30,
    spread: 360,
    origin: { x: 0.18, y: 0.58 }, // 与定向喷射位置一致
    colors: ['#ff6b6b', '#4ecdc4', '#45b7d1', '#f9ca24', '#f0932b', '#eb4d4b', '#6c5ce7', '#a29bfe'],
    shapes: ['circle', 'square'],
    scalar: 0.8,
    drift: 0,
    gravity: 1,
    ticks: 200
  })
  
  // 右侧礼花筒 - Random Direction
  confetti({
    particleCount: 100,
    startVelocity: 30,
    spread: 360,
    origin: { x: 0.82, y: 0.58 }, // 与定向喷射位置一致
    colors: ['#ff6b6b', '#4ecdc4', '#45b7d1', '#f9ca24', '#f0932b', '#eb4d4b', '#6c5ce7', '#a29bfe'],
    shapes: ['circle', 'square'],
    scalar: 0.8,
    drift: 0,
    gravity: 1,
    ticks: 200
  })
}

// 触发五彩纸屑效果
const triggerConfetti = () => {
  // 首先触发定向喷射
  fireConfetti()
  
  // 然后触发随机方向效果
  setTimeout(() => {
    fireRandomConfetti()
  }, 300)
}

// 页面加载时自动触发效果
onMounted(() => {
  setTimeout(() => {
    triggerConfetti()
  }, 800)
})
</script>

<style scoped>
.celebration-container {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  overflow: hidden;
}

/* 礼花筒样式 */
.confetti-cannon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  animation: cannon-pulse 2s infinite ease-in-out;
}

.left-cannon {
  left: 5%;
  transform: translateY(-50%) rotate(-15deg);
}

.right-cannon {
  right: 5%;
  transform: translateY(-50%) rotate(15deg) scaleX(-1);
}

.right-cannon .cannon-body {
    rotate: -85deg;
}

.cannon-body {
  position: relative;
}

.cannon-emoji {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

.cannon-sparkle {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  animation: sparkle 1s infinite ease-in-out alternate;
}

.sparkle-emoji {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

@keyframes cannon-pulse {
  0%, 100% {
    transform: translateY(-50%) scale(1);
  }
  50% {
    transform: translateY(-50%) scale(1.05);
  }
}

.left-cannon .cannon-body {
  animation: cannon-pulse 2s infinite ease-in-out, cannon-shake 0.5s infinite ease-in-out;
}

.right-cannon .cannon-body {
  animation: cannon-pulse 2s infinite ease-in-out, cannon-shake 0.5s infinite ease-in-out;
}

@keyframes cannon-shake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-2px);
  }
  75% {
    transform: translateX(2px);
  }
}

@keyframes sparkle {
  0% {
    opacity: 0.5;
    transform: translateX(-50%) scale(0.8);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) scale(1.2);
  }
}



.celebration-content {
  text-align: center;
  z-index: 10;
  background: rgba(255, 255, 255, 0.9);
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  max-width: 500px;
  margin: 0 auto;
}

.celebration-header {
  margin-bottom: 30px;
}

.congratulations-text {
  font-size: 3rem;
  font-weight: bold;
  color: #333;
  margin: 0;
}


.celebration-message {
  font-size: 1.5rem;
  color: #555;
  margin: 10px 0;
  font-weight: 500;
}

.celebration-icon {
  margin: 30px 0;
}

.trophy {
  animation: bounce 2s infinite;
  display: inline-block;
}

.trophy-emoji {
  width: 100px;
  height: 100px;
  object-fit: contain;
}


.celebration-details {
  margin-top: 30px;
}

.success-message {
  font-size: 1.2rem;
  color: #666;
  margin-bottom: 20px;
  line-height: 1.6;
}

.celebrate-btn {
  background: linear-gradient(45deg, #4ecdc4, #45b7d1);
  border: none;
  padding: 12px 24px;
  font-size: 1rem;
  color: white;
  border-radius: 25px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(78, 205, 196, 0.3);
  letter-spacing: 0.5px;
}

.celebrate-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(78, 205, 196, 0.4);
  background: linear-gradient(45deg, #3bb3b6, #3a9bc1);
}

.celebrate-btn:active {
  transform: translateY(0);
}


/* 奖杯弹跳动画 */
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0) scale(1);
  }
  40% {
    transform: translateY(-25px) scale(1.05);
  }
  60% {
    transform: translateY(-12px) scale(1.02);
  }
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .celebration-content {
    padding: 35px;
    margin: 15px;
    max-width: 450px;
  }
  
  .congratulations-text {
    font-size: 2.5rem;
  }
  
  .cannon-emoji {
    width: 70px;
    height: 70px;
  }
  
  .sparkle-emoji {
    width: 25px;
    height: 25px;
  }
}

@media (max-width: 768px) {
  .celebration-container {
    padding: 10px;
  }
  
  .celebration-content {
    padding: 25px;
    margin: 10px;
    border-radius: 12px;
    max-width: 90%;
  }
  
  .congratulations-text {
    font-size: 2rem;
    line-height: 1.2;
  }
  
  .celebration-message {
    font-size: 1.1rem;
  }
  
  .trophy-emoji {
    width: 80px;
    height: 80px;
  }
  
  .success-message {
    font-size: 1rem;
  }
  
  .celebrate-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
  }
  
  .left-cannon {
    left: 2%;
    transform: translateY(-50%) rotate(-15deg);
  }
  
  .right-cannon {
    right: 2%;
    transform: translateY(-50%) rotate(15deg) scaleX(-1);
  }
  
  .cannon-emoji {
    width: 50px;
    height: 50px;
  }
  
  .sparkle-emoji {
    width: 20px;
    height: 20px;
  }
}

@media (max-width: 480px) {
  .celebration-content {
    padding: 20px;
    margin: 5px;
    max-width: 95%;
  }
  
  .congratulations-text {
    font-size: 1.5rem;
  }
  
  .celebration-message {
    font-size: 1rem;
  }
  
  .trophy-emoji {
    width: 60px;
    height: 60px;
  }
  
  .success-message {
    font-size: 0.9rem;
    margin-bottom: 15px;
  }
  
  .celebrate-btn {
    padding: 8px 16px;
    font-size: 0.8rem;
  }
  
  .cannon-emoji {
    width: 40px;
    height: 40px;
  }
  
  .sparkle-emoji {
    width: 16px;
    height: 16px;
  }
  
}

/* 高分辨率屏幕优化 */
@media (min-width: 1400px) {
  .celebration-content {
    padding: 50px;
    max-width: 600px;
  }
  
  .congratulations-text {
    font-size: 3.5rem;
  }
  
  .celebration-message {
    font-size: 1.8rem;
  }
  
  .trophy-emoji {
    width: 120px;
    height: 120px;
  }
  
  .cannon-emoji {
    width: 100px;
    height: 100px;
  }
  
  .sparkle-emoji {
    width: 35px;
    height: 35px;
  }
}
</style>
